package com.jd.sunny.java.httpclient;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;

public class HttpClientTest {


    public String post() {

        String result = "";
        String content = "";
        try {
            URL url = new URL("http://localhost:8080/ccmis/creditcardnocard/traderequst/getInformation");
            URLConnection urlConnection = url.openConnection();
            urlConnection.setDoOutput(true);//���ÿ���������
            OutputStreamWriter osw = new OutputStreamWriter(urlConnection.getOutputStream());
            //������д�ַ�
            osw.write("doGet");
            osw.flush();
            osw.close();

            //���ܷ�������

            InputStreamReader isr = new InputStreamReader(urlConnection.getInputStream());
            BufferedReader br = new BufferedReader(isr);
            while ((content = br.readLine()) != null) {
                result = result + content + "\n";
            }

        } catch (MalformedURLException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return result;

    }

    /**
     * @param args
     */
    public static void main(String[] args) {

        HttpClientTest hct = new HttpClientTest();
        String result = hct.post();
        System.out.println(result);
    }

}
